package com.yanqu.road.server.game.message;

import com.yanqu.road.queue.AutoDriveQueue;
import com.yanqu.road.queue.ICommandQueue;
import com.yanqu.road.server.GameServer;
import com.yanqu.road.server.task.GameCommandTask;

public class SequentialMessageExecuter implements ICommandQueue {
    private AutoDriveQueue<Runnable> commandQueue;

    public SequentialMessageExecuter() {
        this.commandQueue = new AutoDriveQueue<>(GameServer.getServerCommandExecutor());
    }

    @Override
    public AutoDriveQueue<Runnable> getCommandQueue() {
        if (commandQueue == null) {
            commandQueue = new AutoDriveQueue<>(GameServer.getServerCommandExecutor());
        }
        return commandQueue;
    }

    public void addCommandTask(GameCommandTask commandTask) {
        commandQueue.add(commandTask);
    }
}
